﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace CarlosMisfortune.model
{
    public class GameObject
    {
        #region Fields
        protected Vector2 m_worldPos;
        protected Vector2 m_velocity;
        protected int m_frameWidth;
        protected int m_frameHeight;
        
        protected bool m_enabled;
        protected bool m_flipped = false;
        protected bool m_onGround;
        
        protected Rectangle m_collisionRectangle;
        protected int m_collideWidth;
        protected int m_collideHeight;

        //used to determine if blocks marked as "Enemy blocked" should be treated as impassable. 
        //This should only be true if the GameObject is not a player.
        protected bool m_isPlayer = false;
        
        //0,75 will draw the game objects in the middle of the layers, between interactive layer 1 & 2. hopefully.
        protected float m_drawDepth = 0.75f;
        #endregion

        #region Properties
        public bool Enabled
        {
            get { return m_enabled; }
            set { m_enabled = value; }
        }

        public bool IsPlayer
        {
            get { return m_isPlayer; }
            set { m_isPlayer = value; }
        }

        public bool OnGround
        {
            get { return m_onGround; }
            set { m_onGround = value; }
        }

        public bool Flipped
        {
            get { return m_flipped; }
            set { m_flipped = value; }
        }

        public int FrameWidth
        {
            get { return m_frameWidth; }
            set { m_frameWidth = value; }
        }

        public int FrameHeight
        {
            get { return m_frameHeight; }
            set { m_frameHeight = value; }
        }

        public float DrawDepth
        {
            get { return m_drawDepth; }
            set { m_drawDepth = value; }
        }

        public Vector2 WorldPos
        {
            get { return m_worldPos; }
            set { m_worldPos = value; }
        }

        public Vector2 Velocity
        {
            get { return m_velocity; }
            set { m_velocity = value; }
        }

        public float VelocityY
        {
            set { m_velocity.Y = value; }
        }

        public float VelocityX
        {
            set { m_velocity.X = value; }
        }

        public Vector2 WorldCenter
        {
            get
            {
                return new Vector2(
                    (int)m_worldPos.X + (int)(m_frameWidth / 2),
                    (int)m_worldPos.Y + (int)(m_frameHeight / 2));
            }
        }

        public Rectangle WorldRectangle
        {
            get 
            {
                return new Rectangle(
                    (int)m_worldPos.X,
                    (int)m_worldPos.Y,
                    m_frameWidth,
                    m_frameHeight);
            }
        }


        public Rectangle CollisionRectangle
        {
            get
            {
                return new Rectangle(
                    (int)m_worldPos.X + m_collisionRectangle.X,
                    (int)m_worldPos.Y + m_collisionRectangle.Y,
                    m_collisionRectangle.Width,
                    m_collisionRectangle.Height);
            }
            set { m_collisionRectangle = value; }
        }
        #endregion

        #region Constructors

        #endregion

        #region Helper Methods
        
        #endregion

        #region Public Methods
       
        #endregion        
    }
}
